/**
 * <copyright>
 * </copyright>
 *
 * $Id$
 */
package CarProject.impl;

import CarProject.CarProjectPackage;
import CarProject.Champs;
import CarProject.Primaire;
import CarProject.Table;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;
import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Table</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link CarProject.impl.TableImpl#getPossede <em>Possede</em>}</li>
 *   <li>{@link CarProject.impl.TableImpl#getClePrimaire <em>Cle Primaire</em>}</li>
 *   <li>{@link CarProject.impl.TableImpl#getNom <em>Nom</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TableImpl extends EObjectImpl implements Table {
	/**
	 * The cached value of the '{@link #getPossede() <em>Possede</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getPossede()
	 * @generated
	 * @ordered
	 */
	protected EList possede;

	/**
	 * The cached value of the '{@link #getClePrimaire() <em>Cle Primaire</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getClePrimaire()
	 * @generated
	 * @ordered
	 */
	protected Primaire clePrimaire;

	/**
	 * The default value of the '{@link #getNom() <em>Nom</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNom()
	 * @generated
	 * @ordered
	 */
	protected static final String NOM_EDEFAULT = null;

	/**
	 * The cached value of the '{@link #getNom() <em>Nom</em>}' attribute.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getNom()
	 * @generated
	 * @ordered
	 */
	protected String nom = NOM_EDEFAULT;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TableImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected EClass eStaticClass() {
		return CarProjectPackage.Literals.TABLE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList getPossede() {
		if (possede == null) {
			possede = new EObjectContainmentEList(Champs.class, this, CarProjectPackage.TABLE__POSSEDE);
		}
		return possede;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Primaire getClePrimaire() {
		return clePrimaire;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetClePrimaire(Primaire newClePrimaire, NotificationChain msgs) {
		Primaire oldClePrimaire = clePrimaire;
		clePrimaire = newClePrimaire;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, CarProjectPackage.TABLE__CLE_PRIMAIRE, oldClePrimaire, newClePrimaire);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setClePrimaire(Primaire newClePrimaire) {
		if (newClePrimaire != clePrimaire) {
			NotificationChain msgs = null;
			if (clePrimaire != null)
				msgs = ((InternalEObject)clePrimaire).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - CarProjectPackage.TABLE__CLE_PRIMAIRE, null, msgs);
			if (newClePrimaire != null)
				msgs = ((InternalEObject)newClePrimaire).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - CarProjectPackage.TABLE__CLE_PRIMAIRE, null, msgs);
			msgs = basicSetClePrimaire(newClePrimaire, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CarProjectPackage.TABLE__CLE_PRIMAIRE, newClePrimaire, newClePrimaire));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String getNom() {
		return nom;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setNom(String newNom) {
		String oldNom = nom;
		nom = newNom;
		if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, CarProjectPackage.TABLE__NOM, oldNom, nom));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case CarProjectPackage.TABLE__POSSEDE:
				return ((InternalEList)getPossede()).basicRemove(otherEnd, msgs);
			case CarProjectPackage.TABLE__CLE_PRIMAIRE:
				return basicSetClePrimaire(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case CarProjectPackage.TABLE__POSSEDE:
				return getPossede();
			case CarProjectPackage.TABLE__CLE_PRIMAIRE:
				return getClePrimaire();
			case CarProjectPackage.TABLE__NOM:
				return getNom();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case CarProjectPackage.TABLE__POSSEDE:
				getPossede().clear();
				getPossede().addAll((Collection)newValue);
				return;
			case CarProjectPackage.TABLE__CLE_PRIMAIRE:
				setClePrimaire((Primaire)newValue);
				return;
			case CarProjectPackage.TABLE__NOM:
				setNom((String)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void eUnset(int featureID) {
		switch (featureID) {
			case CarProjectPackage.TABLE__POSSEDE:
				getPossede().clear();
				return;
			case CarProjectPackage.TABLE__CLE_PRIMAIRE:
				setClePrimaire((Primaire)null);
				return;
			case CarProjectPackage.TABLE__NOM:
				setNom(NOM_EDEFAULT);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case CarProjectPackage.TABLE__POSSEDE:
				return possede != null && !possede.isEmpty();
			case CarProjectPackage.TABLE__CLE_PRIMAIRE:
				return clePrimaire != null;
			case CarProjectPackage.TABLE__NOM:
				return NOM_EDEFAULT == null ? nom != null : !NOM_EDEFAULT.equals(nom);
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public String toString() {
		if (eIsProxy()) return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (Nom: ");
		result.append(nom);
		result.append(')');
		return result.toString();
	}

} //TableImpl
